﻿@using MyFileView.Shard.Model;
@model  PreviewFileResponseModel
@{
    Layout = null;


    if (Model == null)
    {
        <h1>没有数据</h1>
        return;
    }

}

<h2>PdfPreview</h2>

<script src="https://unpkg.com/pdfobject@2.3.0/pdfobject.js"></script>
<style type="text/css">
    html, body, #pdf_viewer {
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
    }
</style>

<body>
    <div id="pdf_viewer"></div>
</body>
<script type="text/javascript">
      var url = "@Request.UrlReferrer@Model.Url.FirstOrDefault()";

      if (PDFObject.supportsPDFs) {
          // PDF嵌入到网页
          PDFObject.embed(url, "#pdf_viewer");
      } else {
          location.href = "/canvas";
      }

      // 还可以通过以下代码进行判断是否支持PDFObject预览
      if (PDFObject.supportsPDFs) {
          console.log("Yay, this browser supports inline PDFs.");
      } else {
          console.log("Boo, inline PDFs are not supported by this browser");
      }
</script>
